﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Worktool
{
    public partial class ReportBedarfstermine : Form
    {
        public ReportBedarfstermine()
        {
            InitializeComponent();
            this.Text = "Bedarfstermine: " + Properties.Settings.Default.CurrentDBName; 
        }

        private void ReportBedarfstermine_Load(object sender, EventArgs e)
        {
            // TODO: Diese Codezeile lädt Daten in die Tabelle "ASCDataSet.vw_std_manufacturer". Sie können sie bei Bedarf verschieben oder entfernen.
            this.vw_std_manufacturerTableAdapter.Fill(this.ASCDataSet.vw_std_manufacturer);
            this.vw_rep_BereitstellungsterminlisteTableAdapter.Fill(this.ASCDataSet.vw_rep_Bereitstellungsterminliste);
            this.vw_rep_BereitstellungstermineTableAdapter.Fill(this.ASCDataSet.vw_rep_Bereitstellungstermine);
            
            comboBox1.Text = "";
            comboBox2.Text = "";
            this.reportViewer1.RefreshReport();
        }

        private void comboBox1_TextChanged(object sender, EventArgs e)
        {
            try
            {

                if (comboBox2.Text == "")
                {
                    vw_rep_BereitstellungstermineBindingSource.Filter = string.Format("Bedarfstermin = '{0}'", (comboBox1.Text));
                    this.reportViewer1.RefreshReport();
                }
                else
                {
                    vw_rep_BereitstellungstermineBindingSource.Filter = string.Format("Bedarfstermin = '{0}' AND Manufacturer LIKE '{1}'", comboBox1.Text, comboBox2.Text);
                    this.reportViewer1.RefreshReport();
                }
            }
            catch (Exception ex)
            {
            }
        }

        private void comboBox2_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (comboBox1.Text == "")
                {
                    vw_rep_BereitstellungstermineBindingSource.Filter = string.Format("Manufacturer LIKE '{0}'", (comboBox2.Text + "*"));
                    this.reportViewer1.RefreshReport();
                }
                else
                {
                    vw_rep_BereitstellungstermineBindingSource.Filter = string.Format("Bedarfstermin = '{0}' AND Manufacturer LIKE '{1}'", comboBox1.Text, (comboBox2.Text+"*"));
                    this.reportViewer1.RefreshReport();
                }
            }
            catch (Exception ex)
            {
            }
        }
    }
}
